﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Windows.Forms;

namespace DXWindowsApplication3
{
    class DataProvider
    {

        public static SqlConnection ConnectionData()
        {
            string str = "Data Source=DARK_KOOL-PC\\SQLEXPRESS;Initial Catalog=QLRapChieuPhim;Persist Security Info=True;User ID=sa;Password=123";
            SqlConnection cn;
            cn = new SqlConnection(str);
            cn.Open();
            return cn;
        }
        public static DataTable LoadTable(string sql)
        {
            SqlConnection cn = DataProvider.ConnectionData();
            SqlDataAdapter da = new SqlDataAdapter(sql, cn);
            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt;            
        }
        public static void ExecuteNonQuery(string sql)
        {
            SqlConnection cn = DataProvider.ConnectionData();
            SqlCommand cmd = new SqlCommand(sql, cn);
            cmd.ExecuteNonQuery();
            cn.Close();
        }
    }
}
